/* Forward declarations */
static void gdk_window_set_static_win_gravity (GdkWindow *window,
gboolean on);
-static gboolean gdk_window_have_shape_ext (GdkDisplay *display);
static gboolean gdk_window_icon_name_set (GdkWindow *window);
static void gdk_window_add_colormap_windows (GdkWindow *window);
static void set_wm_name (GdkDisplay *display,
XFree (old_windows);
}
-static gboolean
-gdk_window_have_shape_ext (GdkDisplay *display)
-{
-#ifdef HAVE_SHAPE_EXT
- int ignore;
-
- return XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display),
- &ignore, &ignore);
-#else
- return 0;
-#endif
-}
-
#define WARN_SHAPE_TOO_BIG() g_warning ("GdkWindow is too large to allow the use of shape masks or shape regions.")
/*
* If not available, shaped windows will look
* ugly, but programs still work. Stefan Wille
*/
-/**
- * gdk_window_shape_combine_mask:
- * @window: a #GdkWindow
- * @mask: shape mask
- * @x: X position of shape mask with respect to @window
- * @y: Y position of shape mask with respect to @window
- *
- * Applies a shape mask to @window. Pixels in @window corresponding to
- * set bits in the @mask will be visible; pixels in @window
- * corresponding to unset bits in the @mask will be transparent. This
- * gives a non-rectangular window.
- *
- * If @mask is %NULL, the shape mask will be unset, and the @x/@y
- * parameters are not used.
- *
- * On the X11 platform, this uses an X server extension which is
- * widely available on most common platforms, but not available on
- * very old X servers, and occasionally the implementation will be
- * buggy. On servers without the shape extension, this function
- * will do nothing.
- *
- * This function works on both toplevel and child windows.
- *
- **/
-void
-gdk_window_shape_combine_mask (GdkWindow *window,
- GdkBitmap *mask,
- gint x, gint y)
+static void
+do_shape_combine_mask (GdkWindow *window,
+ GdkBitmap *mask,
+ gint x,
+ gint y,
+ gint shape)
{
GdkWindowObject *private = (GdkWindowObject *)window;
Pixmap pixmap;
return;
}
- if (gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
+ if (shape == ShapeBounding
+ ? gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window))
+ : gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
{
if (mask)
{
pixmap = GDK_PIXMAP_XID (mask);
- private->shaped = TRUE;
+ private->shaped = (shape == ShapeBounding);
}
else
{
XShapeCombineMask (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
- ShapeBounding,
+ shape,
x, y,
pixmap,
ShapeSet);
}
/**
- * gdk_window_shape_combine_region:
+ * gdk_window_shape_combine_mask:
* @window: a #GdkWindow
- * @shape_region: region of window to be non-transparent
- * @offset_x: X position of @shape_region in @window coordinates
- * @offset_y: Y position of @shape_region in @window coordinates
+ * @mask: shape mask
+ * @x: X position of shape mask with respect to @window
+ * @y: Y position of shape mask with respect to @window
*
- * Makes pixels in @window outside @shape_region be transparent,
- * so that the window may be nonrectangular. See also
- * gdk_window_shape_combine_mask() to use a bitmap as the mask.
+ * Applies a shape mask to @window. Pixels in @window corresponding to
+ * set bits in the @mask will be visible; pixels in @window
+ * corresponding to unset bits in the @mask will be transparent. This
+ * gives a non-rectangular window.
+ *
+ * If @mask is %NULL, the shape mask will be unset, and the @x/@y
+ * parameters are not used.
*
- * If @shape_region is %NULL, the shape will be unset, so the whole
- * window will be opaque again. @offset_x and @offset_y are ignored
- * if @shape_region is %NULL.
- *
* On the X11 platform, this uses an X server extension which is
* widely available on most common platforms, but not available on
* very old X servers, and occasionally the implementation will be
*
**/
void
-gdk_window_shape_combine_region (GdkWindow *window,
- GdkRegion *shape_region,
- gint offset_x,
- gint offset_y)
-{
+gdk_window_shape_combine_mask (GdkWindow *window,
+ GdkBitmap *mask,
+ gint x,
+ gint y)
+{
+ do_shape_combine_mask (window, mask, x, y, ShapeBounding);
+}
+
+/**
+ * gdk_window_input_shape_combine_mask:
+ * @window: a #GdkWindow
+ * @mask: shape mask
+ * @x: X position of shape mask with respect to @window
+ * @y: Y position of shape mask with respect to @window
+ *
+ * Like gdk_window_shape_combine_mask(), but the shape applies
+ * only to event handling. Mouse events which happen while
+ * the pointer position corresponds to an unset bit in the
+ * mask will be passed on the window below @window.
+ *
+ * An input shape is typically used with RGBA windows.
+ * The alpha channel of the window defines which pixels are
+ * invisible and allows for nicely antialiased borders,
+ * and the input shape controls where the window is
+ * "clickable".
+ *
+ * On the X11 platform, this requires version 1.1 of the
+ * shape extension.
+ *
+ * Since: 2.10
+ */
+void
+gdk_window_input_shape_combine_mask (GdkWindow *window,
+ GdkBitmap *mask,
+ gint x,
+ gint y)
+{
+#ifdef ShapeInput
+ do_shape_combine_mask (window, mask, x, y, ShapeInput);
+#endif
+}
+
+
+static void
+do_shape_combine_region (GdkWindow *window,
+ GdkRegion *shape_region,
+ gint offset_x,
+ gint offset_y,
+ gint shape)
+{
GdkWindowObject *private = (GdkWindowObject *)window;
gint xoffset, yoffset;
return;
}
- if (gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
+ if (shape == ShapeBounding
+ ? gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window))
+ : gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
{
gint n_rects = 0;
XRectangle *xrects = NULL;
- private->shaped = TRUE;
+ private->shaped = shape == ShapeBounding;
_gdk_region_get_xrectangles (shape_region,
0, 0,
XShapeCombineRectangles (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
- ShapeBounding,
+ shape,
offset_x, offset_y,
xrects, n_rects,
ShapeSet,
#endif /* HAVE_SHAPE_EXT */
}
+/**
+ * gdk_window_shape_combine_region:
+ * @window: a #GdkWindow
+ * @shape_region: region of window to be non-transparent
+ * @offset_x: X position of @shape_region in @window coordinates
+ * @offset_y: Y position of @shape_region in @window coordinates
+ *
+ * Makes pixels in @window outside @shape_region be transparent,
+ * so that the window may be nonrectangular. See also
+ * gdk_window_shape_combine_mask() to use a bitmap as the mask.
+ *
+ * If @shape_region is %NULL, the shape will be unset, so the whole
+ * window will be opaque again. @offset_x and @offset_y are ignored
+ * if @shape_region is %NULL.
+ *
+ * On the X11 platform, this uses an X server extension which is
+ * widely available on most common platforms, but not available on
+ * very old X servers, and occasionally the implementation will be
+ * buggy. On servers without the shape extension, this function
+ * will do nothing.
+ *
+ * This function works on both toplevel and child windows.
+ *
+ **/
+void
+gdk_window_shape_combine_region (GdkWindow *window,
+ GdkRegion *shape_region,
+ gint offset_x,
+ gint offset_y)
+{
+ do_shape_combine_region (window, shape_region, offset_x, offset_y, ShapeBounding);
+}
+
+/**
+ * gdk_window_input_shape_combine_region:
+ * @window: a #GdkWindow
+ * @shape_region: region of window to be non-transparent
+ * @offset_x: X position of @shape_region in @window coordinates
+ * @offset_y: Y position of @shape_region in @window coordinates
+ *
+ * Like gdk_window_shape_combine_region(), but the shape applies
+ * only to event handling. Mouse events which happen while
+ * the pointer position corresponds to an unset bit in the
+ * mask will be passed on the window below @window.
+ *
+ * An input shape is typically used with RGBA windows.
+ * The alpha channel of the window defines which pixels are
+ * invisible and allows for nicely antialiased borders,
+ * and the input shape controls where the window is
+ * "clickable".
+ *
+ * On the X11 platform, this requires version 1.1 of the
+ * shape extension.
+ *
+ * Since: 2.10
+ */
+void
+gdk_window_input_shape_combine_region (GdkWindow *window,
+ GdkRegion *shape_region,
+ gint offset_x,
+ gint offset_y)
+{
+#ifdef ShapeInput
+ do_shape_combine_region (window, shape_region, offset_x, offset_y, ShapeInput);
+#endif
+}
+
/**
* gdk_window_set_override_redirect:
static void
gdk_propagate_shapes (Display *disp,
Window win,
- gboolean merge)
+ gboolean merge,
+ int shape)
{
Window rt, par, *list = NULL;
gint i, j, num = 0, num_rects = 0;
/* set the rects as the shape mask */
if (rects)
{
- XShapeCombineRectangles (disp, win, ShapeBounding, 0, 0, rects, num_rects,
+ XShapeCombineRectangles (disp, win, shape, 0, 0, rects, num_rects,
ShapeSet, YXSorted);
g_free (rects);
}
{
g_return_if_fail (GDK_IS_WINDOW (window));
+
#ifdef HAVE_SHAPE_EXT
if (!GDK_WINDOW_DESTROYED (window) &&
- gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
+ gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window), FALSE);
+ GDK_WINDOW_XID (window), FALSE, ShapeBounding);
#endif
}
* This function is distinct from gdk_window_set_child_shapes()
* because it includes @window's shape mask in the set of shapes to
* be merged.
- *
**/
void
gdk_window_merge_child_shapes (GdkWindow *window)
#ifdef HAVE_SHAPE_EXT
if (!GDK_WINDOW_DESTROYED (window) &&
- gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
+ gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
+ gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window), TRUE, ShapeBounding);
+#endif
+}
+
+/**
+ * gdk_window_set_child_input_shapes:
+ * @window: a #GdkWindow
+ *
+ * Sets the input shape mask of @window to the union of input shape masks
+ * for all children of @window, ignoring the input shape mask of @window
+ * itself. Contrast with gdk_window_merge_child_input_shapes() which includes
+ * the input shape mask of @window in the masks to be merged.
+ *
+ * Since: 2.10
+ **/
+void
+gdk_window_set_child_input_shapes (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+#ifdef HAVE_SHAPE_EXT
+#ifdef ShapeInput
+ if (!GDK_WINDOW_DESTROYED (window) &&
+ gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window), TRUE);
+ GDK_WINDOW_XID (window), FALSE, ShapeInput);
+#endif
#endif
}
+/**
+ * gdk_window_merge_child_input_shapes:
+ * @window: a #GdkWindow
+ *
+ * Merges the input shape masks for any child windows into the
+ * input shape mask for @window. i.e. the union of all input masks
+ * for @window and its children will become the new input mask
+ * for @window. See gdk_window_input_shape_combine_mask().
+ *
+ * This function is distinct from gdk_window_set_child_input_shapes()
+ * because it includes @window's input shape mask in the set of
+ * shapes to be merged.
+ *
+ * Since: 2.10
+ **/
+void
+gdk_window_merge_child_input_shapes (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+#ifdef HAVE_SHAPE_EXT
+#ifdef ShapeInput
+ if (!GDK_WINDOW_DESTROYED (window) &&
+ gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
+ gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window), TRUE, ShapeInput);
+#endif
+#endif
+}
+
+
static void
gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on)
{
static GQuark quark_extension_event_mode = 0;
static GQuark quark_parent_window = 0;
static GQuark quark_shape_info = 0;
+static GQuark quark_input_shape_info = 0;
static GQuark quark_colormap = 0;
static GQuark quark_pango_context = 0;
static GQuark quark_rc_style = 0;
quark_extension_event_mode = g_quark_from_static_string ("gtk-extension-event-mode");
quark_parent_window = g_quark_from_static_string ("gtk-parent-window");
quark_shape_info = g_quark_from_static_string ("gtk-shape-info");
+ quark_input_shape_info = g_quark_from_static_string ("gtk-input-shape-info");
quark_colormap = g_quark_from_static_string ("gtk-colormap");
quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
quark_rc_style = g_quark_from_static_string ("gtk-rc-style");
shape_info->offset_y);
}
+ shape_info = g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info);
+ if (shape_info)
+ gdk_window_input_shape_combine_mask (widget->window,
+ shape_info->shape_mask,
+ shape_info->offset_x,
+ shape_info->offset_y);
+
if (!GTK_WIDGET_NO_WINDOW (widget))
{
mode = gtk_widget_get_extension_events (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (GTK_WIDGET_HAS_SHAPE_MASK (widget))
- gtk_widget_shape_combine_mask (widget, NULL, -1, -1);
+ gtk_widget_shape_combine_mask (widget, NULL, 0, 0);
+
+ if (g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info))
+ gtk_widget_input_shape_combine_mask (widget, NULL, 0, 0);
if (GTK_WIDGET_REALIZED (widget))
{
GdkRectangle rect;
GdkRegion *region;
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
if (!GTK_WIDGET_REALIZED (widget))
return;
gtk_widget_reparent_fixup_child (GtkWidget *widget,
gpointer client_data)
{
- g_return_if_fail (client_data != NULL);
+ g_assert (client_data != NULL);
if (GTK_WIDGET_NO_WINDOW (widget))
{
GtkStyle *new_style = NULL;
gboolean initial_emission;
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
GtkWidgetAuxInfo *aux_info;
gboolean changed = FALSE;
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
g_object_freeze_notify (G_OBJECT (widget));
aux_info = _gtk_widget_get_aux_info (widget, TRUE);
* gtk_widget_set_size_request(). To get the size a widget will
* actually use, call gtk_widget_size_request() instead of
* this function.
- *
**/
-
void
gtk_widget_get_size_request (GtkWidget *widget,
gint *width,
* mask. This function can't be used with #GTK_NO_WINDOW widgets;
* to get events on those widgets, place them inside a #GtkEventBox
* and receive events on the event box.
- *
**/
void
gtk_widget_set_events (GtkWidget *widget,
static void
gtk_widget_real_map (GtkWidget *widget)
{
- g_return_if_fail (GTK_WIDGET_REALIZED (widget) == TRUE);
+ g_assert (GTK_WIDGET_REALIZED (widget));
if (!GTK_WIDGET_MAPPED (widget))
{
static void
gtk_widget_real_realize (GtkWidget *widget)
{
- g_return_if_fail (GTK_WIDGET_NO_WINDOW (widget));
+ g_assert (GTK_WIDGET_NO_WINDOW (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
if (widget->parent)
shape_info->offset_x = offset_x;
shape_info->offset_y = offset_y;
- /* set shape if widget has a gdk window allready.
- * otherwise the shape is scheduled to be set by gtk_widget_realize.
+ /* set shape if widget has a gdk window already.
+ * otherwise the shape is scheduled to be set by gtk_widget_realize().
*/
if (widget->window)
gdk_window_shape_combine_mask (widget->window, shape_mask,
}
}
+/**
+ * gtk_widget_input_shape_combine_mask:
+ * @widget: a #GtkWidget.
+ * @shape_mask: shape to be added, or %NULL to remove an existing shape.
+ * @offset_x: X position of shape mask with respect to @window.
+ * @offset_y: Y position of shape mask with respect to @window.
+ *
+ * Sets an input shape for this widget's GDK window. This allows for
+ * windows which react to mouse click in a nonrectangular region, see
+ * gdk_window_input_shape_combine_mask() for more information.
+ *
+ * Since: 2.10
+ **/
+void
+gtk_widget_input_shape_combine_mask (GtkWidget *widget,
+ GdkBitmap *shape_mask,
+ gint offset_x,
+ gint offset_y)
+{
+ GtkWidgetShapeInfo* shape_info;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ /* set_shape doesn't work on widgets without gdk window */
+ g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
+
+ if (!shape_mask)
+ {
+ if (widget->window)
+ gdk_window_input_shape_combine_mask (widget->window, NULL, 0, 0);
+
+ g_object_set_qdata (G_OBJECT (widget), quark_input_shape_info, NULL);
+ }
+ else
+ {
+ shape_info = g_slice_new (GtkWidgetShapeInfo);
+ g_object_set_qdata_full (G_OBJECT (widget), quark_input_shape_info,
+ shape_info,
+ (GDestroyNotify) gtk_widget_shape_info_destroy);
+
+ shape_info->shape_mask = g_object_ref (shape_mask);
+ shape_info->offset_x = offset_x;
+ shape_info->offset_y = offset_y;
+
+ /* set shape if widget has a gdk window already.
+ * otherwise the shape is scheduled to be set by gtk_widget_realize().
+ */
+ if (widget->window)
+ gdk_window_input_shape_combine_mask (widget->window, shape_mask,
+ offset_x, offset_y);
+ }
+}
+
+
static void
gtk_reset_shapes_recurse (GtkWidget *widget,
GdkWindow *window)